package service.impl;


import entity.Video;
import mapper.VideoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import service.VideoService;
import utils.Page;

import java.util.List;

/**
 * @Description
 * @Author 李楚鹏
 * @Date 2024/12/30 下午3:29
 **/
@Service("VideoService")

public class VideoServiceImpl implements VideoService {

    @Autowired(required = false)
    private VideoMapper videoMapper;

    @Override
    public List<Video> select(Video video) {
        return videoMapper.select(video);
    }

    @Override
    public Page<Video> findPage(Video video, Integer pageNo, Integer pageSize) {
        Page<Video> page = new Page<Video>();
        page.setPageSize(pageSize);
        // 查询总数，计算总页数
        Integer count = videoMapper.count(video);
        page.setTotalCount(count);
        page.setPageNo(pageNo);
        // 查询分页数据
        Integer pageBegin=(pageNo-1)*pageSize;
        List<Video> data = videoMapper.getPage(video, page.offset(), page.getPageSize());
        page.setData(data);
        return page;
    }


    @Override
    public boolean save(Video video) {
        return false;
    }

    @Override
    public Video findById(Long id) {
        return null;
    }
}
